<?php
namespace BP\Sys;

use BP\En\EntityMyPK;

require_once("BP/En/Map.php");
class CField extends EntityMyPK {
	public function getAttrs () 
	{
		return $this->GetValStringByKey(CFieldAttr::$Attrs);
	}
	public function setAttrs ($value) // [String value]
	{
		$this->SetValByKey(CFieldAttr::$Attrs, $value);
	}
	public function getFK_Emp () 
	{
		return $this->GetValStringByKey(CFieldAttr::$FK_Emp);
	}
	public function setFK_Emp ($value) // [String value]
	{
		$this->SetValByKey(CFieldAttr::$FK_Emp, $value);
	}
	public function getEnsName () 
	{
		return $this->GetValStringByKey(CFieldAttr::$EnsName);
	}
	public function setEnsName ($value) // [String value]
	{
		$this->SetValByKey(CFieldAttr::$EnsName, $value);
	}
	public static function constructor__ () 
	{
		$me = new self();
		return $me;
	}
	public static function constructor__String_String ($FK_Emp, $className) // [String FK_Emp, String className]
	{
		$me = new self();
		$i = $me->Retrieve(CFieldAttr::$FK_Emp, $FK_Emp, CFieldAttr::$EnsName, $className);
		if (($i == 0))
		{
			$me->setEnsName($className);
			$me->setFK_Emp($FK_Emp);
			$me->Insert();
		}
		return $me;
	}
	public function getEnMap () 
	{
		if (($this->get_enMap() != NULL))
		{
			return $this->get_enMap();
		}
		$map = new Map("Sys_UserRegedit", "列�?�择");
		$map->Java_SetEnType($EnType->Sys);
		$map->Java_SetDepositaryOfEntity($Depositary->None);
		$map->AddMyPK();
		$map->AddTBString(CFieldAttr::$EnsName, NULL, "实体类名�?",  FALSE ,  TRUE , 0, 100, 10);
		$map->AddTBString(CFieldAttr::$FK_Emp, NULL, "工作人员",  FALSE ,  TRUE , 0, 100, 10);
		$map->AddTBStringDoc(CFieldAttr::$Attrs, NULL, "属�?�s",  TRUE ,  FALSE );
		$this->set_enMap($map);
		return $this->get_enMap();
	}
	protected function beforeUpdateInsertAction () 
	{
		$this->setMyPK((($this->getEnsName() . "_") . $this->getFK_Emp()));
		return parent->beforeUpdateInsertAction();
	}
	public static function GetMyAttrs ($ens, $map) // [Entities ens, Map map]
	{
		$vals = SystemConfig::GetConfigXmlEns("ListAttrs", $ens);
		if (($vals . NULL))
		{
			return $map->getAttrs();
		}
		$attrs = new Attrs();
		foreach ($map->getAttrs() as $attr) 		{
			if ($vals->contains((("," . $attr->getKey()) . ",")))
			{
				$attrs->Add($attr);
			}
		}
		return $attrs;
	}
}
?>
